from selenium.webdriver.common.by import By

from base.page_base import BasePage
from config import BASE_URL


class Login(BasePage):
    login_url = BASE_URL + "/common/member/login"
    keywords=(By.ID, "keywords")
    password=(By.ID, "password")
    login_btn=(By.ID, "login-btn")
    success_text=(By.CLASS_NAME,'a-link1')
    error_text=(By.CSS_SELECTOR,'span.ng-binding')

    def open_url(self):
        self.driver.get(BASE_URL +"/common/member/login")
    def input_keywords(self,keywords ):
        self.base_input(self.keywords, keywords)
    def input_password(self, password):
        self.base_input(self.password, password)
    def click_login_btn(self):
        self.base_click(self.login_btn)
    def get_success_text(self):
        return self.fd_element(self.success_text).text
    def get_error_text(self):
        return self.fd_element(self.error_text).text
    def login(self,keywords,password):
        self.input_keywords(keywords)
        self.input_password(password)
        self.click_login_btn()

